﻿@{
    ViewBag.Title = "AdditionAccount";
}
<script type="text/javascript">
    var permission_organize_index_UserID;
    var permission_organize_index_UserName;
    $(function () {
        gridUserGet_AdditionAccount();
    });
    function gridUserGet_AdditionAccount() {
        $("#UserDetail_permission_organize_index").jqGrid({
            url: "/Permission/Organize/GetEmptyUser",
            datatype: "json",
            mtype: "post",
            colNames: ['ID', '用户名', '默认角色', '描述'],
            colModel: [
                        { name: 'Id', index: 'Id', width: 20, align: "center", sortable: false, hidden: true },
                        { name: 'UserName', index: 'UserName', width: 100, align: "center", sortable: false },
                        { name: 'RoleName', index: 'RoleName', width: 100, align: "center", sortable: false },
                       { name: 'Description', index: 'Description', width: 250, align: "center", sortable: false }
                       ],
            beforeRequest: function (d) {
            },
            loadError: function (xhr, status) {
                alertMsg.error(xhr.responseText);
            },
            loadComplete: function (xhr) {
                var ajaxbg = $("#background,#progressBar,#lui_UserDetail_permission_organize_index");
                ajaxbg.hide();
            },
            onSelectRow: User_GetIDAndName,
            autowidth: true,
            shrinkToFit: true,
            multiselect: false,
            multiselectWidth: 50,
            sortable: false,
            viewrecords: true,
            sortorder: "desc",
            jsonReader: {
                repeatitems: false
            },
            rowNum: -1,
            height: 280
        }).navGrid('#pager', { edit: false, add: false, del: false, refresh: false, search: false });
    }
    function User_GetIDAndName() {
        var GridObj_UserDetails = $("#UserDetail_permission_organize_index");
        var listCount = GridObj_UserDetails.jqGrid("getGridParam", "selrow"); 
        if (listCount != "") {
            permission_organize_index_UserID = GridObj_UserDetails.getCell(parseInt(listCount), "Id").toString();
            permission_organize_index_UserName = GridObj_UserDetails.getCell(parseInt(listCount), "UserName").toString()
        }
    }
    $("#btnSave_UserDetail_permission_organize_index").click(function () {
        $.post("/Permission/Organize/AddAccounting", {
            "StaffID": "@ViewBag.StaffID",
            "UserID": permission_organize_index_UserID,
            "UserName": permission_organize_index_UserName
        }, function (json) {
            if (json.statusCode == DWZ.statusCode.ok) {
                $("#li_AdditionAccount_permission_organize_index").hide();
                $("#List_Permission_Organize_DutyDetails").trigger("reloadGrid"); //重新加载JqGrid  
                $.pdialog.closeCurrent();
                alertMsg.correct(json.message);
            } else {
                alertMsg.error(json.message);
            }
        }, "json");
    });
    
</script>
<div class="pageContent">
    <div class="pageFormContent" layouth="58">
        <div class="tableList" layouth="60">
            <table class="list" id="UserDetail_permission_organize_index" style="width: 99%">
            </table>
            <div id="pager_UserDetail_Index">
            </div>
        </div>
    </div>
    <div class="formBar">
        <ul>
            <li>
                <div class="buttonActive">
                    <div class="buttonContent">
                        <button type="button" id="btnSave_UserDetail_permission_organize_index">
                            确定</button></div>
                </div>
            </li>
            <li>
                <div class="button">
                    <div class="buttonContent">
                        <button type="button" class="close">
                            取消</button></div>
                </div>
            </li>
        </ul>
    </div>
</div>
